package com.test.prolenders.bean_prolenders.userinfo_prolenders;

import android.content.Context;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.test.prolenders.R;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;

public class LnAplyDetailInfo_prolenders {

    private static class Inner {
        private static LnAplyDetailInfo_prolenders instance = new LnAplyDetailInfo_prolenders();
    }

    private LnAplyDetailInfo_prolenders() {}

    public static LnAplyDetailInfo_prolenders getInstance() {
        return Inner.instance;
    }

    public static void parse(JSONObject obj) {
        Inner.instance = new Gson().fromJson(obj.toString(), LnAplyDetailInfo_prolenders.class);

        Inner.instance.detailItemList.clear();
        JSONArray param = obj.optJSONArray("detailItemList");
        Gson gson = new Gson();
        if (param!=null){
            for (int i=0;i<param.length();i++){
                try {
                    Inner.instance.detailItemList.add(gson.fromJson(param.optString(i), LnAplyItem_prolenders.class));
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }

    }

    private String repayAmount;
    private String realAmount;
    private String processingVatFee;
    private String repayProVatFee;
    private String currency;
    private String repayProFee;
    private String bankAccount;//尼日、乌干达、肯尼亚
    private String overdueRate;
    private String interest;
    private String amount;
    private String processingFee;
    private String walletMobile;//加纳
    private String days;
    private String isShowWaitTips;//是否显示审核页提示文案
    private String waitTipsTitle;//审核页提示文案标题
    private String waitTipsText;//审核页提示文案内容
    //申请页显示配置信息
    private final ArrayList<LnAplyItem_prolenders> detailItemList = new ArrayList<>();

    public String getRpAmount() {
        if (TextUtils.isEmpty(repayAmount)) return "";
        return repayAmount;
    }

    public String getRealAmount() {
        if (TextUtils.isEmpty(realAmount)) return "";
        return realAmount;
    }

    public String getProcessingVatFee() {
        if (TextUtils.isEmpty(processingVatFee)) return "";
        return processingVatFee;
    }

    public String getRpProVatFee() {
        if (TextUtils.isEmpty(repayProVatFee)) return "";
        return repayProVatFee;
    }

    public String getCurrency() {
        if (TextUtils.isEmpty(currency)) return "";
        return currency;
    }

    public String getRpProFee() {
        if (TextUtils.isEmpty(repayProFee)) return "";
        return repayProFee;
    }

    public String getBkAccount_NiUgKe() {
        if (TextUtils.isEmpty(bankAccount)) return "";
        return bankAccount;
    }

    public Double getOvduRate() {

        if (TextUtils.isEmpty(overdueRate)) return 0d;

        try {
            return Double.parseDouble(overdueRate)*100;
        }catch (NumberFormatException e){
            e.printStackTrace();
            return 0d;
        }

    }

    public String getInterest() {
        if (TextUtils.isEmpty(interest)) return "";
        return interest;
    }

    public String getAmount() {
        if (TextUtils.isEmpty(amount)) return "";
        return amount;
    }

    public String getProcessingFee() {
        if (TextUtils.isEmpty(processingFee)) return "";
        return processingFee;
    }

    public String getWltMobile_Gh() {
        if (TextUtils.isEmpty(walletMobile)) return "";
        return walletMobile;
    }

    public String getDays() {
        if (TextUtils.isEmpty(days)) return "";
        return days;
    }

    public String getTermStr(Context context){

        try {
            int dayInt = Integer.parseInt(days);
            if (dayInt <= 1) return context.getString(R.string.day_prolenders,dayInt);
            else return context.getString(R.string.days_prolenders,dayInt);
        }catch (NumberFormatException e){
            e.printStackTrace();
            return context.getString(R.string.day_prolenders,0);
        }

    }

    public boolean isShowWaitTips(){
        if (TextUtils.isEmpty(isShowWaitTips)) return false;
        return isShowWaitTips.equalsIgnoreCase("YES");
    }

    public String getWaitTipsTitle() {
        if (TextUtils.isEmpty(waitTipsTitle)) return "";
        return waitTipsTitle;
    }

    public String getWaitTipsText() {
        if (TextUtils.isEmpty(waitTipsText)) return "";
        return waitTipsText;
    }

    public ArrayList<LnAplyItem_prolenders> getDetailItemList() {
        return detailItemList;
    }
}
